package priv.stones.controller.administrate;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import priv.stones.common.annotation.CommitLog;
import priv.stones.common.utils.Result;
import priv.stones.common.utils.config.GlobalConfig;
import priv.stones.common.utils.config.WebSite;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Author: Stones
 * @Description:
 * @Date: 2017/10/25 17:07
 */
@Controller
@RequestMapping("/administrate/setting")
public class SettingController extends BaseController {

    @RequestMapping("")
    public String Index(Model model) {
        return FreeMarkerViewResult("setting/index", model);
    }

    @RequestMapping(value = "/website/save", method = RequestMethod.POST)
    @CommitLog("修改网站配置")
    @ResponseBody
    public Result UpdateWebSite(HttpServletRequest request, WebSite webSite) throws IOException {
        GlobalConfig.setWebSite(webSite);
        return Result.Ok();
    }


}
